<template>
  <div class="menu">
    <div class="header">
      <div>
        智能调度系统
      </div>
      <div>
        <el-button class="logout-btn" type="text" @click="logout">
          退出
        </el-button>
      </div>
    </div>
    <div class="menu-items">
      <router-link class="menu-item menu1" to="/tagbind">
        <span>标签绑定</span>
      </router-link>
      <router-link class="menu-item menu2" to="/tagUnbind">
        <span>标签解绑</span>
      </router-link>
      <router-link class="menu-item menu3" to="/productionOrder">
        <span>生产工单</span>
      </router-link>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { SapOrderForm, SapOrderQuery, SapOrderVO } from '@/api/painting/sapOrder/types';
import { useUserStore } from '@/store/modules/user';
import { ElMessageBoxOptions } from "element-plus/es/components/message-box/src/message-box.type";

const router = useRouter();
const userStore = useUserStore();

const logout = async () => {
  await ElMessageBox.confirm('确定注销并退出系统吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  } as ElMessageBoxOptions);
  userStore.logout().then(() => {
    router.replace({
      path: '/login',
      // query: {
      //   redirect: encodeURIComponent(router.currentRoute.value.fullPath || '/')
      // }
    });
  });
}
</script>

<style lang="scss" scoped>
.menu {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f5f5f5;
  box-sizing: border-box;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background-color: #409eff;
  color: white;
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

  .back-icon {
    font-size: 24px;
    cursor: pointer;
  }

  .logout-btn {
    color: white;
    font-size: 16px;
  }
}

.menu-items {
  display: flex;
  flex-wrap: wrap;
  // gap: 20px;
  padding: 20px;
  justify-content: space-evenly;
  /* 改为从左侧开始排列 */
  // align-content: flex-start;
  /* 顶部对齐 */
  overflow-y: auto;
  /* 允许内容过多时滚动 */
  flex: 1;
  /* 填充剩余空间 */
}

.menu-item {
  flex: 1 1 auto;
  min-width: 230px;
  /* 最小宽度 */
  max-width: 370px;
  /* 最大宽度 */
  display: flex;
  justify-content: center;
  align-items: center;
  height: 150px;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-decoration: none;
  color: #333;
  font-size: 18px;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;

  /* 添加背景图标或装饰 */
  &::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background-color: rgba(64, 158, 255, 0.1);
    border-bottom-left-radius: 40px;
  }

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    background-color: #f8fafc;
  }

  span {
    padding: 15px 25px;
    text-align: center;
    z-index: 1;
    color: #fff;
  }

  /* 不同菜单项的颜色区分 */
  &.menu1 {
    background-image: linear-gradient(#3fbcf0, #1889e1);
  }

  &.menu2 {
    background-image: linear-gradient(#ffa069, #f86f61);
  }

  &.menu3 {
    background-image: linear-gradient(#f9c962, #e8af19);
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .menu-item {
    flex: 0;
    font-size: 17px;

    span {
      padding: 10px 15px;
    }
  }
}

@media (min-width: 431px) and (max-width: 767px)  {
  .menu-items {
    align-content: space-around;
  }

  .menu-item {
    flex: 1 1 100%;
    height: 150px;
    /* 手机端稍矮 */
    font-size: 16px;
    /* 手机端字体稍小 */
    min-width: 200px;
    max-width: 370px;

    span {
      padding: 10px 15px;
    }
  }
}

@media (max-width: 430px) {
  .menu-items {
    align-content: space-around;
  }

  .menu-item {
    flex: 1 1 100%;
    height: 100px;
    /* 手机端稍矮 */
    font-size: 16px;
    /* 手机端字体稍小 */
    min-width: 200px;
    max-width: 230px;

    span {
      padding: 10px 15px;
    }
  }
}
</style>
